<template>
    <view class="taskDetails">
        <uni-nav-bar fixed left-icon="left" :title="title" @clickLeft="backHandle" class="unibarS">
            <!-- <block slot="right">
                <text class="sub-btn" @click="submit">新建回款</text>
            </block> -->
        </uni-nav-bar>
        <!-- 主要内容 -->
        <view class="taskDetails-content">
            <!-- 任务信息 -->
            <view class="customer-info">
                <view class="customer-row">
                    <view class="item">
                        <view>订单编号</view>
                        <view>{{ detailsData.refundNumber }}</view>
                    </view>
                    <view class="item">
                        <view>审批状态</view>
                        <view>{{ bus_examine_status[detailsData.approvalStatus] }}</view>
                    </view>
                    <view class="item">
                        <view>退款金额</view>
                        <view>¥ {{ detailsData.refundAmount }}</view>
                    </view>
                </view>
                <view class="customer-row">
                    <view class="item">
                        <view>退款日期</view>
                        <view>{{ detailsData.createTime }}</view>
                    </view>
                    <view class="item">
                        <view>退款方式</view>
                        <view>{{ detailsData.refundType == 0? '全部退货' : detailsData.refundType == 1? '部分退款' : detailsData.refundType == 2? '无需退回' : '---'}}</view>
                    </view>
                    <view class="item">
                        <view>负责人员</view>
                        <view>{{ detailsData.submitterName }}</view>
                    </view>
                </view>
            </view>
            <view class="info-c">
                <view>
                    <view class="item-title">基本信息</view>
                    <view class="item-content">
                        <view class="item-content-row">
                            <view>退款日期</view>
                            <view>{{ detailsData.createTime }}</view>
                        </view>
                        <view class="item-content-row">
                            <view>退款金额</view>
                            <view>{{ detailsData.refundAmount }}</view>
                        </view>
                        <view class="item-content-row">
                            <view>关联客户</view>
                            <view>{{ detailsData.customerName }}</view>
                        </view>
                        <view class="item-content-row">
                            <view>退款方式</view>
                            <view>{{ detailsData.refundType == 0? '全部退货' : detailsData.refundType == 1? '部分退款' : detailsData.refundType == 2? '无需退回' : '---'}}</view>
                        </view>
                        <view class="item-content-row">
                            <view>付款方式</view>
                            <view>---</view>
                        </view>
                        <view class="item-content-row">
                            <view>负责人员</view>
                            <view>{{ detailsData.submitterName }}</view>
                        </view>
                        <!-- <view class="item-content-row">
                            <view>附件下载</view>
                            <view>---</view>
                        </view> -->
                        <view class="item-content-row">
                            <view>退款描述</view>
                            <view>{{ detailsData.refundDescription }}</view>
                        </view>
                    </view>
                </view>
                <!-- <view>
                    <view class="item-title">审批信息</view>
                    <view class="item-content">
                        <view class="item-content-row">
                            <view>提交人员</view>
                            <view>{{ detailsData.submitterName }}</view>
                        </view>
                        <view class="item-content-row">
                            <view>提交时间</view>
                            <view>{{ detailsData.submissionTime }}</view>
                        </view>
                        <view class="item-content-row">
                            <view>1级审批</view>
                            <view>---</view>
                        </view>
                        <view class="item-content-row">
                            <view>2级审批</view>
                            <view>---</view>
                        </view>
                        <view class="item-content-row">
                            <view>审批状态</view>
                            <view>{{ detailsData.approvalStatus }}</view>
                        </view>
                        <view class="item-content-row">
                            <view>审批时间</view>
                            <view>{{ detailsData.supervisorApprovalTime }}</view>
                        </view>
                        <view class="item-content-row">
                            <view>通知他人</view>
                            <view>{{ detailsData.noticeUserId }}</view>
                        </view>
                    </view>
                </view> -->
            </view>
        </view>
        <!-- 底部 -->
        <view class="bottom-box">
            <template>
                <view class="row-box" @click="delHandle()">
                    <u-icon name="trash-fill" color="#0C1019" size="22"></u-icon>
                    <text>删除记录</text>
                </view>
            </template>
        </view>
        <!--  -->
        <u-action-sheet :actions="list" title="任务处理" @close="close" @select="select" :show="show"></u-action-sheet>
    </view>
</template>

<script>
import { convertToDict } from '@/common/utils'
export default {

    data() {
        return {
            detailsData: {},
            title: '',
            list: [
                { name:'未签到完成', type: 1 },
                { name:'已签到完成', type: 2 }
            ],
            show:false,
        }
    },
    onLoad(options) {
        this.bus_pay_status = convertToDict(JSON.parse(uni.getStorageSync('bus_pay_status')))
        this.bus_examine_status = convertToDict(JSON.parse(uni.getStorageSync('bus_examine_status')))
        if(options.id) {
            this.id = options.id
            this.getDetails()
        }
    },
    methods: {
        getDetails() {
			this.$http.get('/app/refund/' + this.id, {}).then(res => {
                console.log(res)
				if (res.code == 200) {
                    this.detailsData = res.data
                    this.title = res.data.customerName
				} else {
					uni.$u.toast(res.msg)
				}
			})
		},
        openPopup() {
            this.$refs.popup.open()
        },
        delHandle() {
            let that = this
            uni.showModal({
                title: '提示',
                content: '确定要执行此操作吗？',
                success: function (res) {
                    if (res.confirm) {
                        that.$http.del('/app/refund/' + that.detailsData.id, {}).then(res => {
                            let data = res.data
                            if (data.code == 200) {
                                uni.showToast({ title: '成功', duration: 1000 });
                                setTimeout(() => {
                                    uni.navigateBack()
                                }, 1000)
                            } 
                        })
                    } else if (res.cancel) {
                        console.log('用户点击取消');
                    }
                }
            });
        },
        select(item) {
            uni.showModal({
                title: '提示',
                content: '确定要执行此操作吗？',
                success: function (res) {
                    if (res.confirm) {
                        console.log('用户点击确定');
                    } else if (res.cancel) {
                        console.log('用户点击取消');
                    }
                }
            });
        },
        close() {
            this.show = false
        },
        backHandle() {
            uni.navigateBack()
        }
    }
}
</script>

<style lang="scss" scoped>
/deep/.uni-navbar__header-btns-right {
    width: 64px !important;
}

.taskDetails {
    padding-bottom: 150rpx;
}

.taskDetails-content {
    margin: 20rpx 0;

    .customer-info {
        border-radius: 24rpx;
        background: rgba(255, 255, 255, 1);
        padding: 32rpx 0;

        .customer-row-title {
            padding: 0 32rpx;
            text-align: center;
            // 超出隐藏
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        .customer-row {
            display: flex;
            justify-content: space-between;
            text-align: center;

            .item {
                flex: 1;
                padding: 0 32rpx;
                // 超出隐藏
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;

                > :nth-child(1) {
                    font-size: 28rpx;
                    font-weight: 400;
                    color: rgba(103, 117, 133, 1);
                    margin-bottom: 8rpx;
                }

                > :nth-child(2) {
                    width: 100%;
                    font-size: 28rpx;
                    font-weight: 500;
                    color: rgba(12, 16, 25, 1);
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                }
            }
        }
    }

    .item-title {
        padding: 48rpx 32rpx 20rpx 32rpx;
        font-size: 32rpx;
        font-weight: 500;
        color: rgba(12, 16, 25, 1);
    }

    .item-content {
        background: rgba(255, 255, 255, 1);
        padding: 0 32rpx;
        border-radius: 24rpx;

        .item-content-row {
            display: flex;
            justify-content: space-between;
            padding: 26rpx 0;
            font-size: 28rpx;
            border-bottom: 2rpx solid rgba(240, 240, 240, 1);

            >view:nth-child(1) {
                font-weight: 400;
                color: rgba(103, 117, 133, 1);
                width: 140rpx;
            }

            >view:nth-child(2) {
                flex: 1;
                font-weight: 500;
                color: rgba(12, 16, 25, 1);
                // 超出隐藏显示省略号
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                text-align: right;
            }
        }
    }
}

.bottom-box {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0px 0px 12rpx rgba(0, 0, 0, 0.1);
    > view {
        padding: 32rpx 0
    }

    .row-box {
        display: flex;
        align-items: center;
    }
    .column-box {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    text {
        font-size: 28rpx;
        font-weight: 500;
        color: rgba(12, 16, 25, 1);
        margin-left: 8rpx;
    }

}

.popup-box {
    padding: 32rpx 0;

    .popup-header {
        display: flex;
        justify-content: center;
        margin-bottom: 32rpx;
    }

    .icon-box {
        border-radius: 16rpx;
        background: #F2F2F2;
        width: 100rpx;
        height: 100rpx;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .grid-text {
        margin-top: 24rpx;
        margin-bottom: 32rpx;
        font-size: 28rpx;
    }
}
</style>